package cn.itcast.bos.mq;

import org.springframework.stereotype.Service;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

/**
 * 消费者监听并消费传入的消息
 * 每次接受消息就会调用onMessage方法
 */
@Service("smsConsumer")
public class SmsConsumer implements MessageListener{
    @Override
    public void onMessage(Message message) {
        MapMessage mapMessage = (MapMessage) message;
        try {
            System.out.println(mapMessage.getString("telephone"));
            System.out.println(mapMessage.getString("checkCode"));
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
